<?php
declare (strict_types = 1);

namespace app\controller;

use think\Request;

class FormTokenController
{
    public function index(Request $request)
    {
        $token = $request->buildToken('__token__', 'sha1');
        $data  = ['__token___' => $token];

        return view('form-token/index', $data);
    }// index() end

    public function store(Request $request)
    {
        if ($request->checkToken('__token__') === false) return json(['code' => 403, 'message' => 'invalid token'], 200);

        return json(['code' => 200, 'message' => 'token pass'], 200);
    }// store() end
}
